/*
 * Copyright (c) 2008 by 1eEurope (Switzerland) AG, Thalwil
 *
 * Customer:	1eEurope (Switzerland) AG
 * Project:		BKS
 * Created:		30.09.2008, WBL
 *
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace By1eEurope.BKS.Controls
{
    /// <summary>
    /// Definition class of the BKS Image Field Type.
    /// </summary>
    public class ImageField : SPFieldMultiLineText
    {
        public ImageField(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        { this.Init(); }

        public ImageField(SPFieldCollection fields,
                           string typeName,
                           string displayName)
            : base(fields, typeName, displayName)
        { this.Init(); }
        
        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                BaseFieldControl fldControl = new ImageControl();
                fldControl.FieldName = InternalName;
                return fldControl;
            }
        }

        public override object GetFieldValue(string value)
        {
            return new ImageValue(value);
        }

        private void Init()
        {
            this.Template = this.GetCustomProperty("Template") + "";
            this.LongDescReader = this.GetCustomProperty("LongDescReader") + "";
        }

        private string template;
        public string Template
        {
            get { return this.template; }
            set { this.template = value; }
        }

        private string longDescReader;
        public string LongDescReader
        {
            get { return this.longDescReader; }
            set { this.longDescReader = value; }
        }

        public override void Update()
        {
            this.SetCustomProperty("Template", this.Template);
            this.SetCustomProperty("LongDescReader", this.LongDescReader);
            base.Update();
        }

    }
}
